package paint;

import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.util.ArrayList;
import java.util.List;

import base.DreamScript;
import base.DreamUtility;

public class PaintManager extends DreamUtility {
	public List<PaintComponent> chatAreaComponents = new ArrayList<PaintComponent>();
	public List<PaintComponent> inventoryAreaComponents = new ArrayList<PaintComponent>();
	public List<PaintComponent> gameAreaComponents = new ArrayList<PaintComponent>();
	public List<PaintComponent> minimapAreaComponents = new ArrayList<PaintComponent>();

	public PaintManager(DreamScript cs) {
		super(cs);
	}

	public void paint(Graphics g) {
		Graphics2D g2 = (Graphics2D) g;

		g2.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
		g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
		g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB);
		g2.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
		g2.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
		g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);

		for (PaintComponent component : chatAreaComponents) {
			int x = component.getBounds().x;
			int y = component.getBounds().y;

			if (cs.getReflectionFields().resizeable) {
				x += cs.getReflectionFields().GAME_INTERFACE_OFF_X;
				y += cs.getReflectionFields().GAME_INTERFACE_OFF_Y;
			}

			// component.paint(g2, new Point(x, y));
		}

		for (PaintComponent component : inventoryAreaComponents) {
			int x = component.getBounds().x;
			int y = component.getBounds().y;

			if (cs.getReflectionFields().resizeable) {
				x += cs.getReflectionFields().TAB_X_DELTA_FROM_FIXED;
				y += cs.getReflectionFields().GAME_INTERFACE_OFF_Y;
			}

			// component.paint(g2, new Point(x, y));
		}

		for (PaintComponent component : gameAreaComponents) {
			int x = component.getBounds().x;
			int y = component.getBounds().y;

			if (cs.getReflectionFields().resizeable) {
				x += cs.getReflectionFields().GAME_INTERFACE_OFF_X;
				y += cs.getReflectionFields().GAME_INTERFACE_OFF_Y;
			}

			// component.paint(g2, new Point(x, y));
		}

		for (PaintComponent component : minimapAreaComponents) {
			int x = component.getBounds().x;
			int y = component.getBounds().y;

			if (cs.getReflectionFields().resizeable) {
				x += cs.getReflectionFields().MINIMAP.x;
				y += cs.getReflectionFields().MINIMAP.y;
			}

			// component.paint(g2, new Point(x, y));
		}
	}
}
